package nix.spring.tx.dao;

import org.springframework.jdbc.core.support.JdbcDaoSupport;

/*
 create table t_account (
  id int primary key auto_increment,
  name varchar(255),
  money double
 );
 insert into t_account values (null, 'zhangSan', 1000);
 insert into t_account values (null, 'liSi', 1000);
 */
public class AccountDaoImpl extends JdbcDaoSupport implements AccountDao {

	@Override
	public void addMoney(Integer id, Double money) {
		this.getJdbcTemplate().update("update t_account set money = money + ? where id = ?", money, id);
	}

	@Override
	public void subMoney(Integer id, Double money) {
		this.getJdbcTemplate().update("update t_account set money = money - ? where id = ?", money, id);
	}

}
